part of '../repository.dart';

const _kWebOneTimePurchasedItemRevokedKey = 'revoked';
const _kWebOneTimePurchasedItemTransactionIdKey = 'transaction_id';

const _kWebOneTimePurchasedItemTypeValue = 'one_time_purchased_item';

class _WebOneTimePurchasedItemDto extends Equatable implements _WebPurchasedItemDto {
  const _WebOneTimePurchasedItemDto._internal({
    required this.purchaseItemSku,
    required this.transactionId,
    required this.revoked,
  });

  @override
  final String purchaseItemSku;

  final String transactionId;
  final bool revoked;

  @override
  List<Object?> get props {
    return [
      purchaseItemSku,
      transactionId,
      revoked,
    ];
  }

  factory _WebOneTimePurchasedItemDto.fromJson(Map<String, dynamic> json) {
    return _WebOneTimePurchasedItemDto._internal(
      purchaseItemSku: json[_kWebPurchasedItemPurchaseItemSkuKey],
      transactionId: json[_kWebOneTimePurchasedItemTransactionIdKey],
      revoked: json[_kWebOneTimePurchasedItemRevokedKey],
    );
  }

  @override
  WebOneTimePurchasedItem toEntity() {
    return WebOneTimePurchasedItem(
      purchaseItemSku: purchaseItemSku,
      transactionId: transactionId,
      revoked: revoked,
    );
  }
}
